#include <vector>
#include <iostream>

using std::cout;
using std::endl;
using std::vector;

void test()
{
    vector<int> vec;//1、创建无参对象
    //2、count个value值
    /* vector<int> vec(10); */

    //3、迭代器范围
    /* int arr[10] = {1, 4, 7, 9, 8, 6, 2, 5, 10, 12}; */
    /* vector<int> vec(arr, arr + 10);//[,)左闭右开 */

    //4、大括号形式
    /* vector<int> vec = {1, 3, 5, 7, 9, 8, 6, 4, 2, 10}; */
    //5、拷贝或者移动

    //下标
    for(size_t idx = 0; idx != vec.size(); ++idx)
    {
        cout << vec[idx] << "  ";
    }
    cout << endl;

    vector<int>::iterator it;
    for(it = vec.begin(); it != vec.end(); ++it)
    {
        cout << *it << "  ";
    }
    cout << endl;

    vector<int>::iterator it2 = vec.begin();
    for(; it2 != vec.end(); ++it2)
    {
        cout << *it2 << "  ";
    }
    cout << endl;

    //C++11(这种方式背后需要有迭代器做支撑)
    for(auto &elem : vec)
    {
        cout << elem << "  ";
    }
    cout << endl;
}

int main(int argc, char *argv[])
{
    test();
    return 0;
}


